<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>扫码付款~</title>
    <link rel="stylesheet" type="text/css" href="__CSS__/shareh/api222.css"/>
    <link rel="stylesheet" type="text/css" href="__CSS__/shareh/aui222.css"/>
    <style>
        body, html {
            height: 100%;
            margin: 0px;
            background-image: url(__IMG__/shareh/bg33.png);
            background-repeat: no-repeat;
            /*padding-top: 10px;*/
            background-color: #f0f0f0;
            overflow: hidden;
            background-size:100% 200px;
        }

        .all {
            height: 100%;
            background-color: #FFFFFF;
            border-radius: 10px;
            padding-top: 20px;
            margin: 0 20px;
        }

        .imgTop {
            width: 100px;
            height: 100px;
            border-radius: 10px;
            margin: auto;
            margin-top: 20px;

        }

        .name1 {
            line-height: 30px;
            text-align: center;
            /*color: #EBA319;*/
            font-size: 16px;
            font-weight: bold;
        }

        .name2 {
            line-height: 30px;
            color: #000000;
            font-size: 15px;
            font-weight: bold;
            padding: 0 10px;
        }

        .name222 {
            background-color: #EBA000;
            height: 50px;
            line-height: 50px;
            padding: 0 5px;
            color: #ffffff;
            font-size: 14px;
            border-radius: 5px;
            margin-top: 5px;
            font-weight: normal;
            margin-top: -25px;
        }
        .name333 {
            background-color: #ccc;
        }

        .name3 {
            line-height: 30px;
            color: #000000;
            font-size: 14px;
        }

        .name33 {
            color: red;
            font-weight: normal;
            padding-left: 5px;
            font-size: 14px;
        }

        .inputt {
            height: 50px;
            margin: 10px;
            line-height: 50px;
            font-size: 16px;
            color: #000000;
            background-color: #FFF;
            border: 1px solid #FEA76D;
            border-radius: 10px;
            padding-left: 10px;
        }

        .footAll {
            width: 100%;
            height: 210px;
            position: fixed;
            bottom: 0;
            background: #F2F2F2;
            padding: 2px 10px;
        }

        .left1 {
            width: 33%;
            height: 45px;
            background: #FFFFFF;
            border-radius: 6px;
            line-height: 45px;
            text-align: center;
            font-size: 20px;
            color: #000000;
            margin: 3px;
            font-weight: bold;
        }

        .left11 {
            width: 66%;
            height: 45px;
            background: #FFFFFF;
            border-radius: 6px;
            line-height: 45px;
            text-align: center;
            font-size: 20px;
            color: #000000;
            margin: 3px;
            font-weight: bold;
        }

        .right {
            width: 100px;
            background-color: #FFFFFF;
            border-radius: 6px;
            margin: 3px;
            height: 95px;
        }

        .rightImg {
            /*width: 50px;*/
            height: 25px;
            margin: 35px auto;

        }

        .right2 {
            width: 100px;
            background-color: #EBA000;
            border-radius: 6px;
            margin: 3px;
            height: 95px;
            color: #FFFFFF;
            font-size: 16px;
            line-height: 95px;
            text-align: center;
        }

        .money {
            font-weight: bold;
        }

        .aui-input, input[type="text"]{
            border: none;
            background-color: transparent;
            border-radius: 0;
            box-shadow: none;
            display: block;
            padding: 12px;
            margin: 0;
            width: 70px;
            height: 20px;
            line-height: 20px;
            color: #424242;
            font-size: 0.7rem;
            font-family: inherit;
            box-sizing: border-box;
            -webkit-user-select: text;
            user-select: text;
            -webkit-appearance: none;
            appearance: none;
            border-radius: 1px;
            background-color: #E7EAF1;
            margin: 0 0;
            margin-top: 3px;
        }

        .animation1::before {
            content: '';
            display: block;
            width: 1px;
            height: 21px;
            margin-top: 12px;
            margin-left: 15px;
            animation: blink 1s infinite steps(1, start);
        }

        .animation::after {
            content: '';
            display: block;
            width: 1px;
            height: 21px;
            margin-top: 12px;
            animation: blink 1s infinite steps(1, start);
        }

        @keyframes blink {
            0% {
                background-color: white;
            }
            50% {
                background-color: black;
            }
            100% {
                background-color: white;
            }

        }

        .gray {
            color: #CCC;
            padding-left: 10px;
        }

        .moneymoney {
            margin-left: -20px;
        }
        .topImg{
            height: 30px;
            line-height: 30px;
            text-align: left;
            padding-left: 30px;
            width: 100%;
            background-color: #FFF;
            margin-bottom: 20px;
        }
        .topImg img{
            height: 20px;
            display: block;
            float: left;
            margin-top: 5px;
            margin-right: 5px;
        }
        .top_tip {
            height: 30px;
            line-height: 30px;
            text-align: left;
            padding-left: 30px;
            width: 100%;
            background-color: #FFF;
            margin-bottom: 20px;
            display: flex;
        }

        .top_tip img {
            height: 20px;
            width: 20px;
            margin-top: 5px;
        }

        .top_tip marquee {
            flex: 1;
            color: #F96B47
        }
        .hidden{
            display: none;
        }
        .ovfHiden{overflow: hidden;height: 100%;}
    </style>
</head>
<body>
<div class="footAll">


    <div class="flex-wrap">

        <div class="flex-con">

            <div class="flex-wrap">
                <div class="left1">1</div>
                <div class="left1">2</div>
                <div class="left1">3</div>
            </div>

            <div class="flex-wrap">
                <div class="left1">4</div>
                <div class="left1">5</div>
                <div class="left1">6</div>
            </div>

        </div>

        <div class="right">
            <img src="__IMG__/shareh/del.png" alt="" class="rightImg"/>
        </div>

    </div>


    <div class="flex-wrap">

        <div class="flex-con">

            <div class="flex-wrap">
                <div class="left1">7</div>
                <div class="left1">8</div>
                <div class="left1">9</div>
            </div>

            <div class="flex-wrap">
                <div class="left11">0</div>
                <div class="left1">.</div>
            </div>

        </div>

        <div class="right2" onclick="payMoneyJifen(1)">确认付款</div>

    </div>


</div>

<div class="top_tip">
    <img src="__IMG__/shareh/laba.png" alt="">
    <marquee direction="left" scrollamount="4"><span style="color: #f85959">{$shopData[0]['conf_rate']}</span></marquee>
</div>
<div class="all">
    <img src="{$shopImg}" alt="" class="imgTop"/>
    <div class="name1">{$shopName}</div>

    <div class="inputt flex-wrap animation1"><span class="money moneymoney">￥</span><span class="gray mwwprice" id="getJiFen">请输入支付金额</span>
    </div>

    <div class="name2 flex-wrap">
        现金买单
        <!--<div class="flex-con"></div>-->
        <span class="name33" id="sendJifen"></span>
    </div>

    <div class="name2 flex-wrap">
        <div>积分买单【<span style="font-weight: normal;font-size: 14px;">积分</span>:{$user['user_integral']}】</div>
        <input type="text" class="aui-input" disabled id="jifenJifen" value="0" />
        <div class="flex-con"></div>
        <div class="name222 name333" onclick="payMoneyJifen(2)">积分付款</div>
    </div>
    <div style="width: 100%;height: 10px;border-bottom: 1px solid #E6E6E6;"></div>
</div>
<!--支付密码-->
<div class="all_div2" style="display:none;width: 100%;height: 100%;background-color: gray;position: absolute;z-index: 9999;background: rgba(0,0,0,0.5);top: 0;left: 0;padding: 0;margin: 0;text-align: center;">
</div>
<input type="hidden" id="payPass" value="{$user['user_pay_password']}" />
<input type="hidden" id="user_integral" value="{$user['user_integral']}" />
</body>

</html>
<script type="text/javascript" src="__JS__/jquery.min.js"></script>
<script>
    window.alert = function(name){
        var iframe = document.createElement("IFRAME");
        iframe.style.display="none";
        iframe.setAttribute("src", 'data:text/plain,');
        document.documentElement.appendChild(iframe);
        window.frames[0].window.alert(name);
        iframe.parentNode.removeChild(iframe);
    };
    window.confirm = function (message) {
        var iframe = document.createElement("IFRAME");
        iframe.style.display = "none";
        iframe.setAttribute("src", 'data:text/plain,');
        document.documentElement.appendChild(iframe);
        var alertFrame = window.frames[0];
        var result = alertFrame.window.confirm(message);
        iframe.parentNode.removeChild(iframe);
        return result;
    };
</script>
<script type="text/javascript">
    $('.left1,.left11').click(function () {
        if ($('.inputt').hasClass('animation1')) {
            $('.inputt').removeClass('animation1');
            $('.moneymoney').css('margin-left', '-4px');
            $('.inputt').addClass('animation');
        }
        var num = $(this).text();
        if ($('.mwwprice').hasClass('gray')) {
            $('.mwwprice').removeClass('gray');
            $('.mwwprice').text(num)
        } else {
            var aaa = $('.mwwprice').text()
            $('.mwwprice').text(aaa + '' + num);
        }
        sameJifen($('.mwwprice').text());
    });
    $('.right').click(function () {
        if (!$('.mwwprice').hasClass('gray')) {
            var aaa = $('.mwwprice').text();
            aaa=aaa.substring(0,aaa.length-1);
            $('.mwwprice').text(aaa);
            if(aaa == ''){
                $('.inputt').addClass('animation1');
                $('.moneymoney').css('margin-left', '-20px');
                $('.inputt').removeClass('animation');
                $('.mwwprice').addClass('gray');
                $('.mwwprice').text("请输入支付金额");
            }
        }
        sameJifen($('.mwwprice').text());
    });
</script>
<script type="text/javascript">
    var ruleList = {$shopMsgJson};
    var payPass = $('#payPass').val();
    var typetypeee = {$shopType};
    var ratio = {$shopRatio};
    var ratio2 = {$shopRatio2};
    var conf_rate = {$conf_rate};
    var jifen = 0;
    var remarkType = '';
    //----------------------------
    var payMoney = 0;
    var payJifen = 0;
    var myJifen = 0;
    //----------------------------
    function sameJifen(money){
        var jifen_jifen = 0;
        if (money && money != '' && parseFloat(money) > 0 && parseFloat(money) != 'NaN' && parseFloat(money) != 'undefined') {
            for (var i = 0; i < ruleList.length; i++) {
                if (parseFloat(money) >= parseFloat(ruleList[i].rule_cash)) {
                    jifen = ruleList[i].rule_jifen;
                }
            }
            if(typetypeee=='2'){
                var ratioPhp = (10-ratio2)/10;
                jifen=(money*ratioPhp)/conf_rate;
                jifen = roundround(jifen);
            }
            if (jifen > 0) {
                $('#sendJifen').text(" 赠送" + jifen + "积分");
            } else {
                $('#sendJifen').text('');
            }
            //换算一下积分
            jifen_jifen = Math.ceil(parseFloat(money) / 0.14);

        } else {
            jifen = 0;
            $('#sendJifen').text('');
        }
        //
        myJifen = $('#user_integral').val();
        $('#jifenJifen').val(jifen_jifen);
        if(parseInt(myJifen) >= parseInt(jifen_jifen) && parseInt(jifen_jifen) > 0){
            $('.name222').removeClass('name333');
        }else{
            $('.name222').addClass('name333');
        }
    }
    //支付 1 现金   2积分
    //NaN undefined '' 0
    function payMoneyJifen(payType) {
        if(payType == 1){
            payMoney = parseFloat($('#getJiFen').text());
            var remark = '';
            if (payMoney && payMoney != '' && payMoney > 0 && payMoney != 'NaN' && payMoney != 'undefined') {
                //jifen(赠送的积分，不需要了，接口不需要传参。。。)
                $.ajax({
                    url: "{:url('admin/Share/QRcodePayH5')}",
                    type: 'post',
                    data: {
                        type: 1,
                        payment_type: 2,
                        integral: 0,
                        money: payMoney,
                        record_give_jifen: jifen,
                        remark: remark
                    },
                    dataType: 'HTML',
                    success: function (returndata) {
                        if(returndata == 1){
                            alert('收款码错误');
                        }else if(returndata == 2){
                            alert('商家积分不足');
                        }else if(returndata == 3){
                            alert('订单生成失败');
                        }else if(returndata == 4){
                            alert('金额错误！');
                        }else if(returndata == 5){
                            alert('小数点后不能超过两位！');
                        }else{
                            $('.all_div2').css('display','block');
                            $('.all_div2').html(returndata);
                        }
                        return;
                    }
                })
            }else{
                alert('金额错误！');
                return;
            }
        }else{
            if($('.name222').hasClass('name333')){
                return false;
            }
            payJifen = $('#jifenJifen').val();
            myJifen = $('#user_integral').val();
            if(!payJifen || parseInt(payJifen) <= 0){
                alert('请填写积分！');
                return false;
            }
            if(parseInt(payJifen) > parseInt(myJifen)){
                alert('积分不足！');
                return false;
            }else{
                //--------------需要输入密码的时候把这一段放开就行了--start---------------------------
//                if(payPass){
//                    $.ajax({
//                        url:"{:url('admin/Share/inputpass')}",
//                        type:'post',
//                        data:'',
//                        dataType:'html',
//                        success:function(res){
//                            $('.all_div2').css('display','block');
//                            $('.all_div2').html(res);
//                            $("#box input").eq(0).focus();
//                            $('html,body').addClass('ovfHiden');
//                        }
//                    })
//                }else{
//                    location.href = "{:url('admin/Share/setpass')}";
//                }
                //---------------需要输入密码的时候把这一段放开就行了--end---------------------------
                //---------------需要输入密码的时候把这一段直接删掉即可--start---------------------------
                payMoney = parseFloat($('#getJiFen').text());
                if(confirm('是否确定使用'+payJifen+'积分支付本次订单')){
                    $('.all_div2').css('display','block');
                    $('.all_div2').html('' +
                        '<img style="margin-top: 60%;margin-left: 40%;width: 80px;height: 80px;" src="https://csdl.jintianjifen.cn/loading6.gif">' +
                        '');
                    $.ajax({
                        url: "{:url('admin/Share/QRcodePayH5')}",
                        type: 'post',
                        data: {
                            type: 2,
                            payment_type: 0,
                            integral: payJifen,
                            realInputMoney: payMoney,
                            money: 0,
                            remark: '',
                            passwordStr: '20211108',
                            payPass: '20211108'
                        },
                        dataType: 'json',
                        success: function (res) {
                            $('.all_div2').css('display','none');
                            $('.all_div2').html('');
                            if (res.status == 200) {
                                alert('支付成功')
                                setTimeout(function() {
                                    location.href = 'https://csdl.jintianjifen.cn/admin/test/test';
                                },500)
                            } else {
                                alert(res.msg)
//                            location.reload();
                            }
                        }
                    })
                }

                //---------------需要输入密码的时候把这一段直接删掉即可--end---------------------------
            }
        }
    }
    //小数取舍的问题
    function roundround(val){
        //按点.分解成数组
        var numArr = val.toString().split(".");
        //如果为null
        if(numArr=='undefined')
            throw 'number error';
        //如果数组长度大于2
        if(numArr.length>2)
            throw 'number error';
        //如果长度为1
        if(numArr.length==1)
            return numArr[0];
        //格式化小数部份第一个数字
        var i = parseInt(numArr[1].charAt(0));
        var i2 = parseInt(numArr[1].charAt(1));
        //如果大于9
        if(i>=9 && i2>=9)
            return parseInt(numArr[0])+1;
        else
            return parseInt(numArr[0]);

    }
</script>